package com.ketangabc.sdk.Permission;

import android.Manifest;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;

import java.util.List;

import androidx.annotation.NonNull;
import pub.devrel.easypermissions.EasyPermissions;

public class VoicePermission implements EasyPermissions.PermissionCallbacks{

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public void initPermission(Context context) {
        String[] perms = {Manifest.permission.CALL_PHONE
                , Manifest.permission.WRITE_EXTERNAL_STORAGE
                , Manifest.permission.READ_EXTERNAL_STORAGE
                , Manifest.permission.INTERNET
                , Manifest.permission.CAMERA,
                Manifest.permission.READ_PHONE_STATE,
                Manifest.permission.RECORD_AUDIO,
                Manifest.permission.ACCESS_COARSE_LOCATION,
                Manifest.permission.ACCESS_FINE_LOCATION
        };

        if (EasyPermissions.hasPermissions(context, perms)) {
            // Already have permission, do the thing
            // ...

        } else {
            // Do not have permissions, request them now
            EasyPermissions.requestPermissions(context, "因为功能需要，需要使用相关权限，请允许",
                    100, perms);
        }
    }

    @Override
    public void onPermissionsGranted(int requestCode, List<String> perms) {

    }

    @Override
    public void onPermissionsDenied(int requestCode, List<String> perms) {

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

    }
}
